package com.group.Service.Impl;

import com.group.DAO.ComplaintDAO;
import com.group.Enity.Complaint;
import com.group.Service.ComplaintService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.sql.Timestamp;
import java.util.Date;
import java.util.List;

@Service
public class ComplaintServiceImpl implements ComplaintService {

    @Autowired
    private ComplaintDAO complaintDAO;

    @Override
    public List<Complaint> getComplaints(Integer status,Integer comId) {
        return complaintDAO.getComplaints(status,comId);
    }

    @Override
    public void addComplaint(int comid, String remarks) {
        Date date=new Date();
        Timestamp comDate = new Timestamp(date.getTime()); // 让日期时间转换为数据库中的timestamp类型

        complaintDAO.addComplaint(comid,remarks,comDate);
    }

    @Override
    public void delById(int id) {
        complaintDAO.delById(id);
    }

    @Override
    public void updateStatus(int id) {
        complaintDAO.update(id);
    }
}
